package com.ztesoft.ossup.report.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.ztesoft.ossup.report.domain.ReportCondition;
import com.ztesoft.ossup.report.domain.ReportConditionEnum;

/**
 * @author chenzb
 *
 */
public interface ReportConditionEnumRepo extends JpaRepository<ReportConditionEnum, Long>, JpaSpecificationExecutor<ReportConditionEnum>{
	
	List<ReportConditionEnum> findByStype(String stype);
	
	@Query(value = "select item_name name,item_val code,name title,sort_order,stype from report_condition_enum where STYPE = ?1", nativeQuery = true)	
	List<ReportConditionEnum> selectDataByStype(String stype);
	
	@Query(value="delete from report_condition_enum T WHERE T.stype in (select enum_code from report_condition where report_id = ?1)",nativeQuery = true)
	@Modifying
	void deleteConditionEnumByReportId(Long reportId);
	
	@Query(value="select distinct stype from report_condition_enum", nativeQuery = true)
	List<ReportConditionEnum> queryStype();
	
}
